/**
* @author Ashish Gupta
* CVSSP, University of Surrey
* Copyright (c) 2010 Ashish Gupta
* All rights reserved.
*/
/**
 * 
 */
package image;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

import projFn.ProjFn;

/**
 * @author Ashish
 *
 */
public class Img {
	private String imageName = "";
	private Integer classType = 0;
	private ArrayList<Integer> hashCode = new ArrayList<Integer>();
	private Double[] histogram = null;
	
	public Img(int numBins){
		this.histogram = new Double[numBins];
	}
	
	public void computeHistogram(ProjFn projFn){
		for(int i = 0; i < this.hashCode.size(); i++){
			int idx = projFn.getProjFn().get(this.hashCode.get(i));
			this.histogram[idx]++;
		}
	}
	
	public void readHashCodeFile(String hashCodeFolderName) throws IOException{
		String fileName = hashCodeFolderName + this.imageName + ".hash";
		File file = new File(fileName);
		FileReader fr= new FileReader(file);
		BufferedReader br = new BufferedReader(fr);
		String line = null;
		while((line=br.readLine())!=null){
			this.hashCode.add(Integer.parseInt(line));
		}
		br.close();
		fr.close();
	}
	/**
	 * @param classType the classType to set
	 */
	public void setClassType(Integer classType) {
		this.classType = classType;
	}
	/**
	 * @return the classType
	 */
	public Integer getClassType() {
		return classType;
	}
	
	/**
	 * @param hashCode the hashCode to set
	 */
	public void setHashCode(ArrayList<Integer> hashCode) {
		this.hashCode = hashCode;
	}
	/**
	 * @return the hashCode
	 */
	public ArrayList<Integer> getHashCode() {
		return hashCode;
	}
	
	public void incrementHistogram(int idx){
		this.histogram[idx]++;
	}
	/**
	 * @param histogram the histogram to set
	 */
	public void setHistogram(Double[] histogram) {
		this.histogram = histogram;
	}
	/**
	 * @return the histogram
	 */
	public Double[] getHistogram() {
		return histogram;
	}


	/**
	 * @param imageName the imageName to set
	 */
	public void setImageName(String imageName) {
		this.imageName = imageName;
	}


	/**
	 * @return the imageName
	 */
	public String getImageName() {
		return imageName;
	}
	
}
